package com.avantis.common.repository;

import com.avantis.common.entity.SysSerialNumber;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: tracywang
 * @Date: 2019/2/15
 * @Descrption:
 */
@Repository
public interface SysSerialNumberRepository extends JpaRepository<SysSerialNumber, Integer>, JpaSpecificationExecutor {

    @Query("select s from SysSerialNumber s where s.id= :id")
     SysSerialNumber findByUuid(@Param("id")String id);

    @Query("select e from SysSerialNumber e ORDER BY e.createdon DESC")
    List<SysSerialNumber> findAllByCreatedOnDesc();

    SysSerialNumber findByModuleCode(String moduleCode);

    @Modifying
    @Query("delete from SysSerialNumber s where s.id= :id")
    void deleteByUuid(@Param("id")String id);
}
